/*
 * @file gkt_widget_select.h
 */

#ifndef GKT_WIDGET_SELECT_H
#define GKT_WIDGET_SELECT_H

#include "gkt_types.h"

#ifdef __cplusplus
extern "C" {
#endif

#if defined(GKT_CONFIG_SCREEN_ENABLE) && GKT_CONFIG_SCREEN_ENABLE

enum {
	GKT_WIDGET_SELECT_TYPE_SWITCH = 0,
	GKT_WIDGET_SELECT_TYPE_NUMBER,
	GKT_WIDGET_SELECT_TYPE_MAX
};

enum {
	GKT_WIDGET_SELECT_SWITCH_TYPE_OPEN_CLOSE = 0,
	GKT_WIDGET_SELECT_SWITCH_TYPE_CHINESE_ENGLISH,
	GKT_WIDGET_SELECT_SWITCH_TYPE_MAX
};

enum {
	GKT_WIDGET_SELECT_KEY_LEFT_RIGHT = 0,
	GKT_WIDGET_SELECT_KEY_UP_DOWN,
	GKT_WIDGET_SELECT_KEY_MAX
};

typedef struct _gkt_widget_select_switch_attr {
	uint8_t	type;
	uint8_t	switch_type;
	uint32_t	init_state;
} gkt_widget_select_switch_attr_s;

typedef struct _gkt_widget_select_number_attr {
	uint8_t	type;
	uint8_t	step;
	uint16_t	min;
	uint16_t	max;
	uint16_t	init_value;
	uint32_t	unit_text;
} gkt_widget_select_number_attr_s;

typedef union _gkt_widget_select_attr {
	uint8_t	type;
	gkt_widget_select_number_attr_s	sel_number;
	gkt_widget_select_switch_attr_s	sel_switch;
} gkt_widget_select_attr_u;

#define GKT_WIDGET_SELECT_SWITCH_ATTR(_switch_type, _init_state)	\
	.sel_switch = {	\
		.type = GKT_WIDGET_SELECT_TYPE_SWITCH,	\
		.switch_type = _switch_type,	\
		.init_state = _init_state,	\
	}
#define GKT_WIDGET_SELECT_NUMBER_ATTR(_min, _max, _step, _init_value, _unit_text)	\
	.sel_number = {	\
		.type = GKT_WIDGET_SELECT_TYPE_NUMBER,	\
		.step = _step,	\
		.min = _min,	\
		.max = _max,	\
		.init_value = _init_value,	\
		.unit_text = _unit_text,	\
	}

#define GKT_WIDGET_SELECT_DESC(_flags, \
			_font_size, _fg_color, _bg_color, \
			_x, _y, _w, _h, attr)	\
	GKT_WIDGET_DESC(SELECT, \
			(_flags) | GKT_WIDGET_F_FOCUSABLE | GKT_WIDGET_F_ALIGN_MIDDLE | GKT_WIDGET_F_ALIGN_CENTER, \
			_font_size, _fg_color, _bg_color,	\
			_x, _y, _w, _h, attr)

int gkt_widget_select_event_handler(gkt_widget_s *widget, 
			uint32_t major_type, uint32_t minor_type, 
			uint32_t data);

void gkt_widget_select_switch_set_text_ids(
			uint32_t switch_type, uint32_t text_ids[2]);

int gkt_widget_select_set_value(gkt_widget_id_t widget_id,
			uint32_t value);

int gkt_widget_select_get_value(gkt_widget_id_t widget_id);

#endif

#ifdef __cplusplus
}
#endif

#endif	/* GKT_WIDGET_SELECT_H */

